/*
 * Copyright (c) 2013 WDCY Information Technology Co. Ltd
 * www.wdcy.cc
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * WDCY Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with WDCY Information Technology Co. Ltd.
 */
package com.monkey.web.dto.response.user;


import com.monkey.core.domain.user.User;
import com.monkey.web.shiro.mgt.AppSession;

import java.util.Date;

/**
 * @author Wu Tianqiang
 */
public class OnlineUserJSONDto {
    private Long userId;
    private String host;
    private String sessionId;
    private boolean valid;
    private long timeout;
    private String userAgent;
    private String systemHost;
    private Date lastLogin;
    private Date lastAccess;
    private boolean expired;
    private String account;
    private String nick;

    public OnlineUserJSONDto(AppSession session, User user) {
        this.userId = user.getId();
        this.host = session.getHost();
        this.sessionId = (String) session.getId();
        this.valid = session.isValid();
        this.timeout = session.getTimeout();
        this.userAgent = session.getUserAgent();
        this.systemHost = session.getSystemHost();
        this.lastLogin = session.getStartTimestamp();
        this.lastAccess = session.getLastAccessTime();
        this.expired = session.isExpired();
        this.account = user.getAccount();
        this.nick = user.getNick();
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public boolean isValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }

    public long getTimeout() {
        return timeout;
    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public String getSystemHost() {
        return systemHost;
    }

    public void setSystemHost(String systemHost) {
        this.systemHost = systemHost;
    }

    public Date getLastLogin() {
        return lastLogin;
    }

    public void setLastLogin(Date lastLogin) {
        this.lastLogin = lastLogin;
    }

    public Date getLastAccess() {
        return lastAccess;
    }

    public void setLastAccess(Date lastAccess) {
        this.lastAccess = lastAccess;
    }

    public boolean isExpired() {
        return expired;
    }

    public void setExpired(boolean expired) {
        this.expired = expired;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }
}